Designing Smarter, Safer Battery Management Systems